package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteResearcherService;
import com.ruoyi.system.api.domain.Researcherinfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class RemoteResearcherinfoFallbackFactory implements FallbackFactory<RemoteResearcherService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);



        @Override
        public RemoteResearcherService create(Throwable throwable) {
            // 记录错误日志
            log.error("远程调用失败，进入降级处理", throwable.getMessage());
            System.out.println("用户调用服务失败：{}"+throwable.getMessage());
            return new RemoteResearcherService() {
                @Override
                public R<Researcherinfo> getInfo1(Long researcherId) {
                    // 返回一个封装了默认数据的 R 对象
                    return R.fail("远程调用失败，返回默认值" +throwable.getMessage());
                }
            };
        }


}

